package SpringAOPTest;

import java.lang.reflect.Proxy;
import java.util.ArrayList;
import org.springframework.beans.factory.FactoryBean;
public class MyFactoryBean implements FactoryBean {
    private String target = null;
    private String interf = null;


    @Override
    public Object getObject() throws Exception //在这个方法中我们通过java的代理技术得到了一个代理类，所有的参数都是通过         //XML文件传递给BeanFactory的所以我们需要一个BeanFactory的对象和一个启动运         //行类
    {
        Class[] interClass = new Class[]{Class.forName(interf)};
        Object objTarget = Class.forName(target).newInstance();
        Object objProxy =Proxy.newProxyInstance(Foo.class.getClassLoader(),interClass,new
                MyInvocationHandler(objTarget));

        return objProxy;
    }

    @Override
    public Class getObjectType() {

        return null;
    }

    @Override
    public boolean isSingleton() {

        return false;
    }

    public String getTarget() {
        return target;
    }
    public void setTarget(String target) {
        this.target = target;
    }
    public String getInterf() {
        return interf;
    }
    public void setInterf(String interf) {
        this.interf = interf;
    }
}